﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using FluentValidation.Validators;

namespace NursingHome.Model.Validators.CustomValidators
{
    public class PhoneNumberValidator : PropertyValidator
    {
        public PhoneNumberValidator() : base("{PropertyName} is not a valid phone number")
        { }

        protected override bool IsValid(PropertyValidatorContext context)
        {
            Regex regex = new Regex(@"^\d[\d-.()]{5, 30}$");
            return regex.IsMatch((string)context.PropertyValue);
        }
    }
}
